#!/bin/bash

if [[ -e ${1} ]] ; then
    FILE=${1}
fi
 
# Ensure input file exits
if [[ -z $FILE ]] ; then
    echo "File not found -- exiting."
    exit
fi
 
EXTENSION="${FILE##*.}"
BASE="${FILE%.*}"

# Ensure input file is mp4 
if [ $EXTENSION != "mp4" ]; then
 echo "File not mp4 format -- exiting."
 exit
fi

MP3_FILE=${BASE}.mp3

# Ensure output file not exits
if [[ -f $MP3_FILE ]] ; then
    echo "Mp3 File already found -- exiting."
    exit
fi

ffmpeg -i "${FILE}" -f mp3 -ab 192000 -vn "${MP3_FILE}" 
